package view;

import java.awt.*;
import javax.swing.*;

/**
 *
 * @author www.java2s.com
 * @reference http://www.java2s.com/Code/Java/Swing-JFC/Panelwithbackgroundimage.htm
 *
 */
public class ImagePanel extends JPanel
{
    private Image img;

    public ImagePanel(String img)
    {
        this(new ImageIcon(img).getImage());
    }

    public ImagePanel(Image img)
    {
        this.img = img;
        Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
        setPreferredSize(size);
        setMinimumSize(size);
        setMaximumSize(size);
        setSize(size);
        setLayout(null);
    }

    public void paintComponent(Graphics g)
    {
        g.drawImage(img, 0, 0, null);
    }
}
